<?php

namespace Login\Model;

use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterInterface;
use Zend\InputFilter\InputFilterAwareInterface;

class Login implements InputFilterAwareInterface {
	public $id;
	public $name;
	public $email;
	public $password;
	public function exchangeArray($data) {
		$this->id = ! empty ( $data ['id'] ) ? $data ['id'] : null;
		$this->name = ! empty ( $data ['name'] ) ? $data ['name'] : null;
		$this->password = ! empty ( $data ['password'] ) ? $data ['password'] : null;
	}
	protected $inputFilter;
	public function setInputFilter(InputFilterInterface $inputFilter) {
		throw new \Exception ( "Not use" );
	}
	public function getInputFilter() {
		if (! $this->inputFilter) {
			$inputFilter = new InputFilter ();
			$factory = new InputFactory ();
			
			$inputFilter->add ( $factory->createInput ( array (
					'name' => 'email',
					'required' => true,
					'filter' => array (
							array (
									'name' => 'StripTags' 
							),
							array (
									'name' => 'StringTrim' 
							) 
					),
					'validator' => array (
							array (
									'name' => 'StringLength',
									'options' => array (
											'encoding' => 'UTF-8',
											'min' => 1,
											'max' => 100 
									) 
							) 
					) 
			) ) );
			
			$inputFilter->add ( $factory->createInput ( array (
					'name' => 'password',
					'required' => true,
					'filter' => array (
							array (
									'name' => 'StripTags' 
							),
							array (
									'name' => 'StringTrim' 
							) 
					),
					'validator' => array (
							array (
									'name' => 'StringLength',
									'options' => array (
											'encoding' => 'UTF-8',
											'min' => 1,
											'max'		=>	100
									)
							)
					)
			)));
			$this->inputFilter=$inputFilter;
		}
		return $this->inputFilter;
	}
	
}